<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>es6对象增强写法</title>
</head>
<body>


<script>

  const name = "小张"
  const age = 18
  const height = 160

  //■es5的写法
  const obj = {
    name: name,
    age: age,
    height: height
  }

  //■es6的写法，会按照相同名称变量名自动进行赋值
  const obj1 = {
    name,
    age,
    height
  }

  //■es5的写法
  const obj2 = {
    run: function () {

    },
    eat: function () {

    }
  }

  //■es6的写法
  const obj2 = {
    run() {

    },
    eat() {

    }
  }

</script>

</body>
</html>